package view.mediator.weapon.charge_axe
{
	import flash.system.System;
	
	import model.weapon.WeaponModel;
	
	import org.robotlegs.mvcs.StarlingMediator;
	
	import view.component.weapon.charge_axe.ChargeAxeView;
	import view.event.weapon.charge_axe.ChargeAxeViewEvent;
	
	
	/**
	 * ChargeAxeView界面中介
	 * @author £iang
	 * 
	 */	
	public class ChargeAxeViewMediator extends StarlingMediator
	{
		//-----------------------------
		// variables
		//-----------------------------
		
		/** ChargeAxeView界面 */
		[Inject]
		public var chargeAxeView:ChargeAxeView;
		/** weaponModel */
		[Inject]
		public var weaponModel:WeaponModel;
		
		//-----------------------------
		// properties
		//-----------------------------
		
		//-----------------------------
		// setter&getter
		//-----------------------------
		
		//-----------------------------
		// methods
		//-----------------------------
		
		/**
		 * 注册函数 
		 * 
		 */		
		override public function onRegister():void
		{
			chargeAxeView.otherView.setText( weaponModel.weaponOtherInfoData["charge_axe"] );
			addContextListener( ChargeAxeViewEvent.CHANGE_PAGE, changePageHandler );
		}
		
		//-----------------------------
		// events
		//-----------------------------
		
		/**
		 * 处理请求滚动条容器翻页时派发的消息 
		 * @param event 请求滚动条容器翻页时派发的消息 
		 * 
		 */		
		protected function changePageHandler( event:ChargeAxeViewEvent ):void
		{
			chargeAxeView.changeSCPageIndex( event.newPage );
		}
		
		//-----------------------------
		// dispose
		//-----------------------------
		
		/**
		 * 移除函数 
		 * 
		 */		
		override public function onRemove():void
		{
			removeContextListener( ChargeAxeViewEvent.CHANGE_PAGE, changePageHandler );
			chargeAxeView.mainSC.removeChild( chargeAxeView.listView, true );
			chargeAxeView.listView = null;
			chargeAxeView.mainSC.removeChild( chargeAxeView.detailView, true );
			chargeAxeView.detailView = null;
			chargeAxeView.mainSC.removeChild( chargeAxeView.searchView, true );
			chargeAxeView.searchView = null;
			chargeAxeView.mainSC.removeChild( chargeAxeView.motionView, true );
			chargeAxeView.motionView = null;
			System.gc();
			super.onRemove();
		}
		
		//-----------------------------
		// construction
		//-----------------------------
		
		/**
		 * 构造函数
		 *
		 */
		public function ChargeAxeViewMediator()
		{
			super();
		}
	}
}